import { useFetch } from "#app";
export const useServerRequest = (url: string, opts: any,method:any) => {
    const token = "TOKEN"
    // 配置文件
    const config = useRuntimeConfig()
    return new Promise((resolve, reject) => {
        useFetch(config.public.baseUrl + url, {...opts ,...method}).then(response => {
            if (response.status.value == 'success') {
                return resolve(response.data.value)
            } else {
                ElMessage.error("请求失败")
                return reject("请求失败")
            }

        }).catch(error => {
            console.log(error)
            return reject(error)
        })

    })

}